#include <cassert>
#include <cstring>
#include <iostream>
using namespace std;

int64_t snowflake(int64_t ms, int64_t node_id, int64_t& seq){
  // TODO: 实现雪花ID生成功能。
  return 0;
}

int main() {
  int64_t seq[1024], N, t, x;
  memset(seq, 0, sizeof(seq));
  cin >> N >> t;
  for(string cmd; cin >> cmd >> x;){
    if(cmd == "sync"){
      t = x;
      memset(seq, 0, sizeof(seq));
      cout << "ok\n";
    }else if(cmd == "next"){
      assert(x >= 0 && x < N);
      cout << snowflake(t, x, seq[x]) << '\n';
    }else{
      assert(false);
    }
  }
  return 0;
}
